/*
 * @Author: HeAo
 * @Date: 2021-11-03 10:18:12
 * @LastEditTime: 2021-11-03 12:07:53
 * @LastEditors: HeAo
 * @Description:
 * @FilePath: \web2103-2105\web2103code\4-1-Nodejs\day04\app02\index.js
 * 别乱动！
 */
const express = require('express');
// 导入路由子模块
const userRouter = require('./routes/user')
// 导入中间件
const cookieParser = require('cookie-parser');
const serveStatic = require('serve-static');
const cors = require('cors')

const app = express();

// 中间件的使用
app.use(cookieParser())
app.use(serveStatic('public'))
app.use(cors())

// 路由注入
app.use('/user', userRouter)

// cookie获取
app.get('/getCookie', (req, res) => {
  res.cookie('name', 'zhangsan');
  res.send('cookie获取成功')
})

app.listen(3000, () => {
  console.log('3000 server is running');
})
